package com.czk.grouptask;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

/**
 *
 * @Author ChenZhangKun
 * @Date 2020/9/15 14:56
 */
public class TaskHandover {
    public static void main(String[] args) {
        // 查询自己的任务
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        // 拿到任务
        TaskService taskService = processEngine.getTaskService();
        // 查询任务
        String key="czk";
        String candidate_user="李洪赭";
        Task task = taskService.createTaskQuery()
                .processDefinitionKey(key)
                .taskAssignee(candidate_user)
                .singleResult();
        if (task!=null){
            // 交接任务
            taskService.setAssignee(task.getId(),"闫连山");
            System.out.println("交接任务完成");
        }
    }
}
